#ifndef __POPUPRSAPUBLICKEYMSG_HPP__
#define __POPUPRSAPUBLICKEYMSG_HPP__

#include "PopupAbstractMessage.hpp"
#include <PopupSSL.hpp>

namespace Popup
{
  struct RsaPublicKeyMsg : public AbstractMessage
  {
    enum { RSA_PUBLIC_KEY = 0x1234 };

    RsaPublicKeyMsg(const SslContext *p_sslContext)
    : AbstractMessage(POPUP_MSG_TYPE_RSA_PUBLIC_KEY), sslContext(p_sslContext),
      receivedKey(0), receivedKeySize(0) {}
    RsaPublicKeyMsg(const Message *p_message);
    ~RsaPublicKeyMsg();

    //!@Override
    bool onSend();

    //!@Override
    bool onReceive();

    inline const unsigned char *getKey() const { return receivedKey; }
    inline size_t getSize() const { return receivedKeySize; }

  private:
    const SslContext *sslContext;
    //! RSA key received from a foreign host
    unsigned char *receivedKey;
    size_t receivedKeySize;
  };
}

#endif // __POPUPRSAPUBLICKEYMSG_HPP__
